package cn.kgc.commons.vo;

import lombok.*;

import java.io.Serializable;

/**
 * vo:给前段返回值使用vo
 * dto:service层之间传递数据使用dto
 * entity:与数据库表对应的实体类
 * @param <T>
 */
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@SuppressWarnings("serial")
public class Result<T> implements Serializable {
    private int code;
    private String message;
    private T data;
    private String requestURL;
    //成功
    public static <T>Result ok(T data,String requestURL){
        return Result.builder().code(200).message("success").data(data).requestURL(requestURL).build();
    }
    //失败
    public static <T>Result error(T data,String requestURL,int code,String message){
        return Result.builder().code(500).message(message).data(null).requestURL(requestURL).build();
    }
}
